package secret.test;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;

public class MD5 {
    public static void main(String[] args) {
        String s = "http://waimaiopen.meituan.com/api/v1/poi/mget?app_poi_codes=31&app_id=1235123121& timestamp=1389751221";
        if (getMD5(s).equals(MD5_2.MD5(s))) {
            System.out.println("一样");
            System.out.println(new BigInteger("70").toString(37));
        } else {
            System.out.println("不一样");
        }
        ;
    }

    static String getMD5(String str) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] b1 = str.getBytes();
            byte[] b2 = md.digest(b1);
            System.out.println("b1:" + Arrays.toString(b1) + "\nb2:" + Arrays.toString(b2));
            String code = new BigInteger(1, b2).toString(16);//返回字符串类型的16进制数
            System.out.println("code1:" + code);

            return code;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        }
    }

    static void deMD5() {
        String code = getMD5("加密前文字");

    }


}
